/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.campaign.biz;

import com.aptech.campaign.dao.CampaignDAO;
import com.aptech.campaign.entities.ActualBudget;
import com.aptech.campaign.entities.Campaign;
import com.aptech.campaign.entities.EstimatedBudget;
import com.aptech.campaign.entities.Product;
import com.aptech.campaign.entities.TypeCampaign;
import com.aptech.campaign.entities.TypeOffer;
import java.sql.Date;
import java.util.ArrayList;

/**
 *
 * @author Tai Nguyen
 */
public class CampaignBiz {

    CampaignDAO dao = new CampaignDAO();

    public CampaignBiz() {
    }

    /**
     * get arraylist prodcut
     * @return ArrayList<Product>
     */
    public ArrayList<Product> findByAllProduct() {
        return dao.readByAllProduct();
    }

    /**
     * get arraylist TypeCampaign
     * @return ArrayList<TypeCampaign>
     */
    public ArrayList<TypeCampaign> findByAllTypeCampaign() {
        return dao.readByAllTypeCampaign();
    }

    /**
     * get arraylist TypeOffer
     * @return ArrayList<TypeOffer>
     */
    public ArrayList<TypeOffer> findByAllTypeOffer() {
        return dao.readByAllTypeOffer();
    }

    /**
     * add a new campaign
     * @param Campaign cam
     * @Return the boolean value
     */
    public boolean createCampaign(Campaign cam) {
        return dao.createCampaign(cam);
    }

    /**
     * edit information of campaign
     * @param int campaignID
     * @return the boolean value
     */
    public boolean storeCampaign(int campaignID, String campaignName, int productID, Date startDate, Date endDate, int typeID, int offerID) {
        return dao.updateCampaign(campaignID, campaignName, productID, startDate, endDate, typeID, offerID);
    }

    /**
     * delete a campaign
     * @param int campaignID
     * @return the boolean value
     */
    public boolean removeCampaign(int campaignID) {
        return dao.deleteCampaign(campaignID);
    }

    /**
     * get array of campaigns in database
     * @param
     * @return ArrayList<Campaign> arr
     */
    public ArrayList<Campaign> findByAllCampaign() {
        return dao.readByAllCampaign();
    }

    /**
     * add new TypeCampaign
     * @param TypeCampaign tc
     * @return the boolean value
     */
    public boolean createTypeCampaign(TypeCampaign tc) {
        return dao.createTypeCampaign(tc);
    }

    /**
     * add new TypeOffer
     * @param TypeOffer to
     * @return the boolean value
     */
    public boolean createTypeOffer(TypeOffer to) {
        return dao.createTypeOffer(to);
    }

    /**
     * input estimate budget data for a campaign
     * @param EstimatedBudget etb
     * @return the boolean value
     */
    public boolean inputEstimateBudget(EstimatedBudget etb) {
        return dao.inputEstimateBudget(etb);
    }

    /**
     * get array campaign that dont't complete and allocate yet
     * @param
     * @return ArrayList<Campaign> arr
     */
    public ArrayList<Campaign> findByEstimate() {
        return dao.readByEstimate();
    }

    /**
     * input actual budget data for a campaign has finished
     * @param ActualBudget atb
     * @return the boolean value
     */
    public boolean inputActualBudget(ActualBudget atb) {
        return dao.inputActualBudget(atb);
    }

    /**
     * get array campaign that completed and don't statistic yet
     * @param
     * @return ArrayList<Campaign> arr
     */
    public ArrayList<Campaign> findByActual() {
        return dao.readByActual();
    }

    /**
     * calculate value of SaleVariance
     * @param int campaignID, float actualSale
     * @return float saleVariance value
     */
    public float calSaleVariance(int campaignID, float actualSale) {
        return dao.calSaleVariance(campaignID, actualSale);
    }

    /**
     * calculate value of BudgetVariance
     * @param int campaignID, float actualBudget
     * @return float budgetVariance value
     */
    public float calbudgetVariance(int campaignID, float actualBuget) {
        return dao.calbudgetVariance(campaignID, actualBuget);
    }

    /**
     * @return the lasterror
     */
    public String getLasterror() {
        return dao.getLasterror();
    }

    /**
     * @param lasterror the lasterror to set
     */
    public void setLasterror(String lasterror) {
        dao.setLasterror(lasterror);
    }
}
